package leetcode.weekly.week291;

import java.util.HashSet;
import java.util.Set;

import leetcode.IDebug;

public class Solution3 implements IDebug {

	public int countDistinct(int[] nums, int k, int p) {
		int len = nums.length;
		int ans = 0;
		for (int i = 1; i <= len; i++) {
			Set<String> hash = new HashSet<>();
			for (int j = 0; j <= nums.length - i; j++) {
				int cnt = 0;
				StringBuffer sb = new StringBuffer();
				for (int j2 = 0; j2 < i; j2++) {
					if (nums[j + j2] % p == 0) {
						cnt++;
					}
					sb.append(nums[j + j2]).append('.');
				}
				if (!hash.contains(sb.toString()) &&cnt <= k)
					ans++;
				hash.add(sb.toString());
			}
		}
		return ans;
	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution3 so = new Solution3();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
